{% extends "base.html" %}
{% load staticfiles %}


{% block title %}
	图灵系统 - 提问
{% endblock %}



{% block style %}
    <link rel="stylesheet" type="text/css" href="{% static 'css/tagify.css' %}">
{% endblock %}



{% block content %}

<div id="mainbar" class="container question_box" >

    <form id="post-form" class="post-form" action="{% url 'app_TuringClass:AskSubmit' %}" method="post" onsubmit="return myonsubmit(event)">
        <input type="hidden" name="qualityBanWarningShown" value="False"/>
        <input type="hidden" name="priorAttemptCount" value="0"/>
        <input type="hidden" name="warntags" />

            <div style="position: relative;">
                    <table>
                            <tr>
                            	<h3 style="color:  #313c2c; font-weight: bold;">问题标题</h3>
                            </tr>
                            <tr  style="padding-top: 10px">
                                <input id="title" name="title" type="text" maxlength="300" tabindex="100" placeholder="不超过30字" class="ask-title-field" >
                            </tr>

                    </table>
            </div>


			<div id="post-editor" >
    			<div style="position: relative;">

			        	<!--tool bar可以先不加？
			            <div id="wmd-button-bar" class="wmd-button-bar"></div>
			            -->
			            <table>
			            	<tr>
                            	<h3 style="color:  #313c2c; font-weight: bold;">
                            		问题详情
                            		<!-- <a href="" title="【上传图片说明】在文本编辑框上的菜单栏里找到上传图片按钮，点击后，在弹出的操作框上方选择上传，点击选择文件后选择你要上传的图片，选择好了点击上传到服务器，之后会跳转图片信息界面可以对你的图片进行裁剪，完毕后点击确定完成图片上传，在帮助里有更加详细的流程介绍。">
                            			<span class="glyphicon glyphicon-info-sign pull-right" style="font-size: 15px; color: #000;"></span>
                            		</a> -->
                            		<a href="#" title="上传图片说明：在【上传】处点击【选择文件】-->选择图片-->选完后点击【上传到服务器】-->在【图像信息】处点击【确定】">
                            			<span class="glyphicon glyphicon-info-sign pull-right" style="font-size: 15px; color: #000;"></span>
                            		</a>
                            	</h3>
                            </tr>
                            <tr>
                  				<script type="text/javascript" src="{%static 'ckeditor/ckeditor.js' %}"></script>
					  			<textarea cols="80" id="content" name="post-text" class="ckeditor" rows="10"></textarea>
							    <script type="text/javascript">
			 					    function getContent(){
						        		return CKEDITOR.instances.content.getBody().getText();
						          		//return CKEDITOR.instances.content.getData();    //获取textarea的值
						      		}
					    		</script>
                  			</tr>
			        	</table>

			    </div>

			    <!--
			    <div class="fl" style="margin-top: 8px; height:24px;">&nbsp;</div>
			    <div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>

			    <div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>
				-->

			    <!--
			    <div id="wmd-preview" class="wmd-preview"></div>
			    <div></div>
			    <div class="edit-block">
			        <input id="fkey" name="fkey" type="hidden" value="dd5c49b7a9a265369ac93fb4a2495b22">
			        <input id="author" name="author" type="text">
			    </div>
			    -->
			</div>

            <div style="">
				<div style="margin: 5px 0px">
					<h3 style="color: #313c2c; font-weight:bold; ">添加标签</h3>
					{% for ul in uls %}
					  <div class="form-item">
		              <p style="display: inline; ">
						{% for li in ul %}
		                  <a id="0" onclick="tagify.addTag(this.text);" class="sum_post-tag" style="cursor:pointer;text-decoration: none;color: #666;" title="" rel="">{{li}}</a>
						{% endfor %}
		              </p>
					</div>
					{% endfor %}
					<div>
						<input id="tags" name="tags" type="text" size="30" onkeypress="//tagify_it(event)" tabindex="103" placeholder="请选择相应的标签（手动输入需满足相同的标签名）" ／>
					</div>

				</div>




        		<br>
	            <div id="question-only-section" class="pull-right" >
				    <div class="form-item" style="">
				    	<!--
				        <td >
				            <input name="receive_email" type="checkbox"/>
				            <label for="" class="chkbx_text" style="display: inline">邮箱接收最新回复</label>
				        </td>

						<td>
				            <input name="anonymous" id="" type="checkbox"/>
				            <label for="" class="chkbx_text" style="display: inline">匿名发布</label>
				        </td>
				        -->
				        <td>
				        	<button id="submit-button" class="form-sumbit" >发布</button>
				        </td>
				        <!--可以不加
				        <div id="" style="display: none;">
				            Send me new responses to my posts via email
				            <select id="">
				                <option value="3">every 3 hours</option>
				                <option value="24">daily</option>
				                <option value="168">weekly</option>
				            </select>

				            <div>
				                Send emails to
				                <input id="inbox-opt-int-fc71a1994f064d9387af7b48ac01005c-address" style="width: 300px;"/>
				            </div>
				        </div>
				        -->
				    </div>

	            </div>
        </div>

    </form>
</div>


{% endblock %}



{% block other_script %}
<script type="text/javascript" src = "{% static 'js/tagify.js' %}" ></script>
<script type="text/javascript">
	function myonsubmit(event) {
		// body...

		var regx=new RegExp('[a-zA-z]|[\u4e00-\u9fa5]|[0-9]');
		var reg=/^((<p>(\&nbsp;( )?)*<\/p>)*\n?)*$/;
		if(!regx.test(document.getElementById('title').value)){
			window.alert("问题标题不能为空！");
			return false;
		}
		if (reg.test(CKEDITOR.instances.content.getData())) {
			window.alert("问题详情不能为空！");
			return false;
		}
		if (!regx.test(document.getElementById('tags').value)) {
			window.alert("标签不能为空！");
			return false;
		}
		$('#post-form').find('button[id="submit-button"]').attr('disabled','disabled');
		return true;
			//document.getElementById('post-form').submit();
	}

</script>

{% endblock %}
